/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.isn.atencionemergencia.entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author pool
 */
@Entity
@Table(name = "lesion")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Lesion.findAll", query = "SELECT l FROM Lesion l"),
    @NamedQuery(name = "Lesion.findByCodLesion", query = "SELECT l FROM Lesion l WHERE l.codLesion = :codLesion"),
    @NamedQuery(name = "Lesion.findByDescLesion", query = "SELECT l FROM Lesion l WHERE l.descLesion = :descLesion")})
public class Lesion implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "Cod_Lesion", columnDefinition="CHAR(5) unsigned")
    private String codLesion;
    @Column(name = "Desc_Lesion")
    private String descLesion;
    @JoinColumn(name = "Cod_Ubi_Lesion", referencedColumnName = "Cod_Ubi_Lesion")
    @ManyToOne(optional = false)
    private UbicacionLesion codUbiLesion;
    @JoinColumn(name = "Cod_Tiplesion", referencedColumnName = "Cod_Tiplesion")
    @ManyToOne(optional = false)
    private TipoLesion codTiplesion;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "codLesion")
    private Collection<ResultadoDeOrdenDeAtencionDeEmergencia> resultadoDeOrdenDeAtencionDeEmergenciaCollection;

    public Lesion() {
    }

    public Lesion(String codLesion) {
        this.codLesion = codLesion;
    }

    public String getCodLesion() {
        return codLesion;
    }

    public void setCodLesion(String codLesion) {
        this.codLesion = codLesion;
    }

    public String getDescLesion() {
        return descLesion;
    }

    public void setDescLesion(String descLesion) {
        this.descLesion = descLesion;
    }

    public UbicacionLesion getCodUbiLesion() {
        return codUbiLesion;
    }

    public void setCodUbiLesion(UbicacionLesion codUbiLesion) {
        this.codUbiLesion = codUbiLesion;
    }

    public TipoLesion getCodTiplesion() {
        return codTiplesion;
    }

    public void setCodTiplesion(TipoLesion codTiplesion) {
        this.codTiplesion = codTiplesion;
    }

    @XmlTransient
    public Collection<ResultadoDeOrdenDeAtencionDeEmergencia> getResultadoDeOrdenDeAtencionDeEmergenciaCollection() {
        return resultadoDeOrdenDeAtencionDeEmergenciaCollection;
    }

    public void setResultadoDeOrdenDeAtencionDeEmergenciaCollection(Collection<ResultadoDeOrdenDeAtencionDeEmergencia> resultadoDeOrdenDeAtencionDeEmergenciaCollection) {
        this.resultadoDeOrdenDeAtencionDeEmergenciaCollection = resultadoDeOrdenDeAtencionDeEmergenciaCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (codLesion != null ? codLesion.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Lesion)) {
            return false;
        }
        Lesion other = (Lesion) object;
        if ((this.codLesion == null && other.codLesion != null) || (this.codLesion != null && !this.codLesion.equals(other.codLesion))) {
            return false;
        }
        return true;
    }
    
}
